home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / buffr2.zip / BD2_MAX.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  3KB  |  104 lines

  1. Unit BD2_Max; {Primitive 2-Dimensional BufferedArrays}
  2. {$R-}
  3.  
  4. INTERFACE
  5.  
  6. Uses BND_Max;
  7.  
  8. Type
  9.  
  10.   D2_BufferedArray = Object (BN_Max)
  11.  
  12.                    Procedure Init (ElementsPerDimension : DimensionPtr;
  13.                                   ElementSize : Word; MaxBuffSize : LongInt;
  14.                                   FileName : String);
  15.  
  16.                    Procedure Accept (X,Y : LongInt; Var El; Size : Word);
  17.                                        {Assign the Addressed El}
  18.  
  19.                    Procedure Retrieve (X,Y : LongInt; Var El; Size : Word);
  20.                                          {Get the Addressed El}
  21.  
  22.  
  23.                    Procedure Swap (X1,Y1,X2,Y2 : LongInt);
  24.                               {Swap the 1 and 2 Element}
  25.  
  26.                    Procedure Copy (From : D2_BufferedArray);
  27.                               {Target *MUST* already be initialized}
  28.                               {to the EXACT same parameters as From}
  29.                               {this will save checking for sufficient}
  30.                               {available Memory!}
  31.  
  32. (* no redefinition needed
  33.  
  34.  
  35.                    Function MaxIndex (Index : Byte) : LongInt;
  36.                                      {Return the Max legal Index}
  37.                                      {for the Indexth Dimension}
  38.  
  39.                    Function MaxSize : LongInt;
  40.                                       {Report Total Number of Array Elements}
  41.  
  42.                    Function ElemSize : Word;  {Report Element Size}
  43.  
  44.                    Procedure Destroy;
  45. *)
  46.           End; {D2_BufferedArray}
  47.  
  48.  
  49.  
  50. IMPLEMENTATION
  51.  
  52.  
  53. Procedure D2_BufferedArray.Init;
  54. Begin
  55.   BN_Max.Init (2,ElementsPerDimension,ElementSize,MaxBuffSize,FileName)
  56. End;
  57.  
  58. Procedure D2_BufferedArray.Accept (X,Y : LongInt; Var El; Size : Word);
  59.                                        {Assign the Addressed El}
  60. Var
  61.   I : Byte;
  62. Begin
  63.   I := 0;
  64.   Add1^[I] := X;  {even with range-checking off, the}
  65.   I := 1;
  66.   Add1^[I] := Y;  {compiler generates an error if}
  67.                   {a constant is used here. Dunno why...}
  68.   BN_Max.Accept (El,Add1,2,Size)
  69. End;
  70.  
  71. Procedure D2_BufferedArray.Retrieve (X,Y : LongInt; Var El; Size : Word);
  72.                                          {Get the Addressed El}
  73. Var
  74.   I : Byte;
  75. Begin
  76.   I := 0;
  77.   Add1^[I] := X;
  78.   I := 1;
  79.   Add1^[I] := Y;
  80.   BN_Max.Retrieve (El,Add1,2,Size)
  81. End;
  82.  
  83. Procedure D2_BufferedArray.Swap (X1,Y1,X2,Y2 : LongInt);
  84.                               {Swap the 1 and 2 Element}
  85. Var
  86.   I : Byte;
  87. Begin
  88.   I := 0;
  89.   Add1^[I] := X1;
  90.   Add2^[I] := X2;
  91.   I := 1;
  92.   Add1^[I] := Y1;
  93.   Add2^[I] := Y2;
  94.   BN_Max.Swap (Add1,Add2,2)
  95. End;
  96.  
  97. Procedure D2_BufferedArray.Copy (From : D2_BufferedArray);
  98. {Redefined purely for type-checking}
  99. Begin
  100.   BN_Max.Copy (From)
  101. End;
  102.  
  103. BEGIN
  104. END.